﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Fundamental.Method
{
    internal static class ExtensionMethod
    {
        public static int[] ToIntegerArray(this string str, char delimiter)
        {
            string[] stringArray = str.Split(new[]{delimiter});
            int[] integerArray = new int[stringArray.Length];
            int index = 0;

            foreach (string stringItem in stringArray)
            {
                int result;
                if (!int.TryParse(stringItem, out result))
                {
                    integerArray[index++] = 0;
                }
                else
                {
                    integerArray[index++] = result;
                }
            }
            return integerArray;
        }
    }
}
